package com.manage.platform.controller;

import com.manage.platform.dto.ProfessionalTitleDto;
import com.manage.platform.dto.query.ProfessionalTitlePageQuery;
import com.manage.platform.service.impl.ProfessionalTitleServiceImpl;
import com.manage.platform.utils.R;
import com.manage.platform.utils.RPage;
import com.manage.platform.vo.CommonVo;
import com.manage.platform.vo.ProfessionalTitleVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lk
 */
@AllArgsConstructor
@RestController
@RequestMapping("/professionalTitle")
@Tag(name = "系统管理-职称管理")
public class ProfessionalTitleController {

  private final ProfessionalTitleServiceImpl professionalTitleServiceImpl;

    @PostMapping("/getProfessionalTitlePage")
    @Operation(summary = "查询职称列表(分页)")
    public R<RPage<List<ProfessionalTitleVo>>> getProfessionalTitlePage(@RequestBody ProfessionalTitlePageQuery query){
        return R.ok(professionalTitleServiceImpl.getProfessionalTitlePage(query));
    }

    @GetMapping("/getProfessionalTitleDetails/{id}")
    @Operation(summary = "查询职称详情")
    public R<ProfessionalTitleVo> getProfessionalTitleDetails(@Schema(description = "ID") @PathVariable("id") Long id){
        return R.ok(professionalTitleServiceImpl.getProfessionalTitleDetails(id));
    }

    @PostMapping("/saveProfessionalTitle")
    @Operation(summary = "添加职称")
    public R<Boolean> saveProfessionalTitle(@RequestBody ProfessionalTitleDto dto){
        return R.ok(professionalTitleServiceImpl.saveProfessionalTitle(dto));
    }

    @PutMapping("/updateProfessionalTitle")
    @Operation(summary = "修改职称")
    public R<Boolean> updateProfessionalTitle(@RequestBody ProfessionalTitleDto dto){
        return R.ok(professionalTitleServiceImpl.updateProfessionalTitle(dto));
    }

    @DeleteMapping("/deleteProfessionalTitle/{id}")
    @Operation(summary = "删除职称")
    public R<Boolean> deleteProfessionalTitle(@Schema(description = "ID") @PathVariable("id") Long id){
        return R.ok(professionalTitleServiceImpl.deleteProfessionalTitle(id));
    }

    @GetMapping("/getProfessionalList")
    @Operation(summary = "职称列表(筛选项)")
    public R<List<CommonVo>> getProfessionalList(@Schema(description = "职称名称") @RequestParam(value = "name", required = false) String name) {
        return R.ok(professionalTitleServiceImpl.getProfessionalList(name));
    }

}
